package com.ticket.util;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(filterName = "EncodeFilter",urlPatterns = "/*")
public class EncodeFilter implements Filter {
    public void destroy() {
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");      //处理请求中的中文乱码
        response.setCharacterEncoding("UTF-8");         //处理响应中的乱码
        response.setContentType("text/html;charset=UTF-8");     //处理html页面乱码
        filterChain.doFilter(request,response);//过滤
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
